package Homework5;

import java.util.ArrayList;
import java.util.Collections;

public class ArrayListTools {
    public static ArrayList<Integer> arrayToArrayList(int[] arr){
        ArrayList<Integer> list = new ArrayList<>();

        for (int j : arr) {
            list.add(j);
        }

        return list;
    }

    public static int getMax(ArrayList<Integer> list){
        return Collections.max(list);
    }

    public static int getMin(ArrayList<Integer> list){
        return Collections.min(list);
    }

    public static int getSum(ArrayList<Integer> list){
        int sum = 0;
        for (int i = 0; i < list.size(); i++){
            sum += list.get(i);
        }
        return sum;
    }

    public static double getAvg(ArrayList<Integer> list){
        return (double) getSum(list) / list.size();
    }

    public static void sort(ArrayList<Integer> list){
        Collections.sort(list);
    }
}
